/**
 * 接受actions  自动调用dispatch
 * @param {*} actionCreators  
 * @param {*} dispatch 
 */

function bindActionCreators(actionCreators, dispatch) {
    const boundActions = {}
    for (let key in actionCreators) {
        let actionCreator = actionCreators[key]
        boundActions[key] = bindActionCreator(actionCreator, dispatch)
    }
    return boundActions
}


function bindActionCreator(actionCreator, dispatch) {  // add 

    return function (...args) {
        dispatch(actionCreator.apply(this, args))
    }

}

export default bindActionCreators